<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="${path}/include/bootstrap/css/init.css"/>
<link rel="stylesheet" href="${path}/include/bootstrap/css/bootstrap/bootstrap.min.css"/>
    <link rel="stylesheet" href="${path}/include/bootstrap/css/index.css"/>
    <link rel="stylesheet" href="${path}/include/bootstrap/css/animate.css"/>
    <link rel="stylesheet" href="${path}/include/bootstrap/css/app.css"/>
    <link rel="stylesheet" href="${path}/include/bootstrap/css/bootstrap.main.css"/>
    <link rel="stylesheet" href="${path}/include/bootstrap/css/login.css"/>
</head>
<body>
<nav class="navbar navbar-default" role="navigation" style="color:#cccccc">
	<div style="padding: 0px 200px 0px">
 <div class="navbar-header">
	<a class="navbar-brand" href="#" color="black">在线回答系统</a>
 </div>
 <div>
	<form class="navbar-form navbar-left">
	 <div class="form-group">
		 <span class="glyphicon glyphicon-search"></span>
		 <input type="text" class="form-control" placeholder="输入关键字搜索" id="qTitle">
	 </div>
	 <button type="button" onclick="search();" class="btn btn-default">搜索</button>
	</form>    
	<div class="log-reg ease2">
        
         	<c:choose>
                    <c:when test="${sessionScope.user==null}">
                    	<div style="padding: 10px 5px 0px">
                       	 <a href="javascript:;" class="btn btn-default theme-login">登录</a>
                       	 <a href="javascript:;" class="btn btn-default reg" style="margin-left: 20px;" >注册</a>
                       	</div>
                     </c:when>
                        	
                     <c:otherwise>
            			
            			<div>
            				<div style="color: black;">
            					欢迎<a style="color: green;" href="${path}/login/myinfo/${sessionScope.user.uId}">${sessionScope.user.uName}</a>登陆本系统
                       	 	</div>
                       	 	<div>
                       			 <a href="${path}/ques/index" class="btn btn-default">回到主页</a>
                       			 <a href="" onclick="exit();" style="margin-left: 20px;" class="btn btn-default">退出登录</a>
                       		</div>
                        </div>
                        
                      </c:otherwise>
              </c:choose>
      </div>
 </div>
</div>
</nav>
<!-- 登陆 -->
<div class="theme-popover">
     <div class="theme-poptit" align="center">
          <a href="javascript:;" title="关闭" class="close">×</a>
          <h2>欢迎登陆</h2>
     </div>
     <div class="theme-popbod dform">
           <form class="theme-signin" name="loginform"  method="post"   >
                <ol>
                     <li><strong>邮箱：</strong><input id="uemail"
                     id="loginName" class="ipt" name="email" type="text"  size="20" placeholder="请输入邮箱" /></li>
                     <li><strong>密码：</strong><input id="upwd"
                     id="loginPwd" class="ipt" name="pwd" type="password"  size="20" placeholder="请输入密码" /></li>
                     <li><input class="btn btn-default" type="button" name="button" value=" 登 录 " onclick="LoginAjax();"/></li>
                     <li><span id="loginSpan" style="color: red;"></span>
                </ol>
           </form>
     </div>
</div>
<div class="theme-popover-mask"></div>

<!-- 注册 -->
<div class="theme-popover1">
     <div class="theme-poptit" align="center">
          <a href="javascript:;" title="关闭" class="close">×</a>
          <h2>欢迎注册</h2>
     </div>
           <form class="theme-signin" style="margin-top: 20px;margin-left: 150px" >
                <ol>
                     <li ><strong>邮箱：</strong><input  id="email" onfocus="FocusItem(1)"  onblur="CheckEmail(this);Checkall(this);"
                     	class="ipt"  type="email"   placeholder="请输入邮箱" /><span id="nameSpan" style="color: red;"></span></li>
                     
                     
                      <!--  onfocus="FocusItem(1)" id="email"  onblur="CheckEmail(this);Checkall(this);"
                      		  onblur="CheckPwd(this);Checkall(this)"  onfocus="FocusItem(2)" 
                      		   onblur="CheckRepwd(this);Checkall(this)"  onfocus="FocusItem(3)"
                      		   onblur="CheckPhone(this);Checkall(this)"  onfocus="FocusItem(4)"
                       -->
                     
                     <li><strong>密码：</strong><input onblur="CheckPwd(this);Checkall(this)"  onfocus="FocusItem(2)" id="pwd"
                     class="ipt" type="password"   placeholder="请输入密码" /> <span id="pwdSpan"style="color: red;"></span></li>
                      
                     <li><strong>确认密码：</strong><input   onblur="CheckRepwd(this);Checkall(this)"  onfocus="FocusItem(3)" id="repwd"
                      class="ipt" type="password"   placeholder="请确认密码" /> <span id="repwdSpan"style="color: red;"></span></li>
                       
                       
                       <li><strong>手机：</strong><input  onblur="CheckPhone(this);Checkall(this)"  onfocus="FocusItem(4)" id="phone" 
                       class="ipt"  type="text"  placeholder="请输入手机号" /><span id="phoneSpan" style="color: red;"></span></li>
                      
                     <li><input class="btn btn-default" type="button" 
                     		    id="reg" onclick="RegAjax();"   value=" 注册 " /></li>
                </ol>
           </form>
     </div>
</div>
<div class="theme-popover-mask1"></div> 
</body>
	<script src="${path}/include/bootstrap/js/jquery.js"></script>
		<script src="${path}/include/bootstrap/js/bootstrap.min.js"></script>
		<%-- <script src="${path}/bootstrap/js/demo.js"></script> --%>
		<script src="${path}/include/bootstrap/js/toastr/toastr.min.js"></script>
		<script src="${path}/include/bootstrap/js/metronic.js"></script>
		<script src="${path}/include/bootstrap/js/jquery.blockui.min.js"></script>
		<script src="${path}/include/bootstrap/js/common-boots.js"></script>
		<script src="${path }/include/bootstrap/boots-3.0.0/js/bootstrapValidator.min.js"></script>
		<script src="${path}/include/bootstrap/boots-3.0.0/js/dataform-boots.js"></script>
		<script src="${path}/include/bootstrap/js/datagrid-boots.js"></script>
		<script type="text/javascript" src="${path }/include/bootstrap/plugin/bootstrap-datetimepicker.min.js"></script>
		<script type="text/javascript" src="${path }/include/bootstrap/plugin/bootstrap-datetimepicker.zh-CN.js"></script>
		<script src="${path}/include/bootstrap/js/jquery-ui.custom.min.js"></script>
		<script src="${path}/include/bootstrap/js/morris.min.js"></script>
		<script src="${path}/include/bootstrap/js/moment.min.js"></script>
		<script src="${path}/include/bootstrap/js/ajaxfileupload.js"></script>
		<script src="${path}/include/bootstrap/js/reg.js"></script>
    <script type="text/javascript">
    function exit(){
    	$.ajax({
			cache : true,
			type : "POST",
			url : "<c:url value='/ques/exit'/>",
			error : function(
					request){
				return;
			},
			success : function(data){
				if(data=="0"){
					window.location.href="<c:url value='/ques/index' />";
				}
			}
		});
    }
	function LoginAjax(){
		$.ajax({
			cache : true,
			async : true,
			type : "POST",
			url : "<c:url value='/login/login'/>",
			data :{"email":$('#uemail').val(),"pwd":$('#upwd').val()},
			error : function(
					request){
				return;
			},
			success : function(data){
				if(data=="0"){
					window.location.href="<c:url value='/ques/index' />";
				}else{
					$('#loginSpan').html("用户名或密码错误");
				}
			}
		});
	}
	
	function RegAjax(){
		$.ajax({
			cache : true,
		    async: true,
			type : "POST",
			url : "<c:url value='/login/reg'/>",
			data : {"email":$('#email').val(),"pwd":$('#pwd').val(),"phone":$('#phone').val()},
			error : function(
					request) {
			},
			success : function(
					data) {
					window.location.href="<c:url value='/ques/index' />";
			}
		});
	}
	
	function search(){
		$.ajax({
			cache : true,
			type : "POST",
			url : "<c:url value='/ques/search'/>",
			data : {"qTitle":$('#qTitle').val()},
			error : function(
					request) {
			},
			success : function(
					data) {
				if(data==0){
					window.location.href = "${path}/ques/searchs";
				}
			}
		});
	}
	
	jQuery(document).ready(
			function($) {
				$('.theme-login').click(
						function(){
						$('.theme-popover-mask').fadeIn(100);
						$('.theme-popover').slideDown(200);
						})
				$('.reg').click(
						function(){
						$('.theme-popover-mask1').fadeIn(100);
						$('.theme-popover1').slideDown(200);
						})			
			
				$('.theme-poptit .close').click(function(){
						$('.theme-popover-mask').fadeOut(100);
						$('.theme-popover').slideUp(200);
						$('.theme-popover-mask1').fadeOut(100);
						$('.theme-popover1').slideUp(200);
			})
		})
	</script>
</html>